package com.weng.cloud.service8881.restTemplate;

import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @Author: weng
 * @Date: 2022/2/23
 * @Description: com.weng.cloud.service8881.restTemplate
 */
@RestController
@RequestMapping("/rest")
public class Controller {

/*    @Resource
    private RestTemplate restTemplate;
    @Resource
    private LoadBalancerClient loadBalancerClient;

    private String url = "http://weng-cloud-service-8882/rest/test";
//    private String url = "http://localhost:8882/rest/test";

    @RequestMapping(value = "/test",method = RequestMethod.GET)
    public String test(){
        //选中服务id的实例，参考：https://blog.csdn.net/qq_29479041/article/details/83826550
//        ServiceInstance serviceInstance = this.loadBalancerClient.choose("xxx");
        return this.restTemplate.getForObject(this.url, String.class);
    }*/
}
